/**
 * 订单业务类
 * Created by Jerry on 16/1/11.
 */

var laOrder = angular.module('laOrder', ['laGlobal']);

/**
 * 机票操作类
 */
laOrder.factory('laFlightService', ['$http', 'laGlobalHTTPService', 'laGlobalLocalService', function ($http, laGlobalHTTPService, laGlobalLocalService) {

    var laFlightService = {};
    /**
     * 查询机票信息
     * @param fliInfo
     * @param callBack
     * @constructor
     */
    laFlightService.QueryFlight = function (fliInfo, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_SearchFlight;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = '';
        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.AirportFrom = fliInfo.AirportFrom;
        requestBody.AirportTo = fliInfo.AirportTo;
        requestBody.DepartureTime = fliInfo.DepartureTime;
        if (fliInfo.FlightNum != null && fliInfo.FlightNum != undefined) {
            requestBody.FlightNum = fliInfo.FlightNum;
        }
        if (fliInfo.AdultCabin != null && fliInfo.AdultCabin != undefined) {
            requestBody.AdultCabin = fliInfo.AdultCabin;
        }
        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var fli = data;
                var flightList = new laEntityFlightList();
                if(data.ErrorCode==0){
                    flightList.Code = "0000";
                    flightList.Message = fli.Message;
                }else {
                    flightList.Code=fli.ErrorCode;
                    flightList.Message=fli.Result;
                }
                if (status == true && flightList.Code == laGlobalProperty.laServiceCode_Success) {
                    var flightInfo = JSON.parse(fli.Result);

                    var nFlis = flightInfo.FlightInfos.length;
                    for (var n = 0; n < nFlis; n++) {
                        var flightData = new laEntityFlight();
                        flightData.FlightNum = flightInfo.FlightInfos[n].FlightNum;
                        flightData.AirportFrom = flightInfo.FlightInfos[n].AirportFrom;
                        flightData.AirportFromCH = flightInfo.FlightInfos[n].AirportFromCH;
                        flightData.AirportTo = flightInfo.FlightInfos[n].AirportTo;
                        flightData.AirportToCH = flightInfo.FlightInfos[n].AirportToCH;
                        flightData.Distance = flightInfo.FlightInfos[n].Distance;
                        flightData.DepartureTime = flightInfo.FlightInfos[n].DepartureTime;
                        flightData.ArriveTime = flightInfo.FlightInfos[n].ArriveTime;
                        /*flightData.AirportTax = flightInfo.FlightInfos[n].TaxAdult.AirportTax;
                        flightData.FuelTax = flightInfo.FlightInfos[n].TaxAdult.FuelTax;
                        flightData.OtherTax = flightInfo.FlightInfos[n].TaxAdult.OtherTax;
                        flightData.ChildAirportTax = flightInfo.FlightInfos[n].TaxChild.AirportTax;
                        flightData.ChildFuelTax = flightInfo.FlightInfos[n].TaxChild.FuelTax;
                        flightData.ChildOtherTax = flightInfo.FlightInfos[n].TaxChild.OtherTax;
                        flightData.InfantAirportTax = flightInfo.FlightInfos[n].TaxInfant.AirportTax;
                        flightData.InfantFuelTax = flightInfo.FlightInfos[n].TaxInfant.FuelTax;
                        flightData.InfantOtherTax = flightInfo.FlightInfos[n].TaxInfant.OtherTax;*/
                        flightData.JiXing = flightInfo.FlightInfos[n].JiXing;
                        flightData.JingTing = flightInfo.FlightInfos[n].JingTing;
                        var InfantCaBLen= flightInfo.FlightInfos[n].InfantCabinInfos.length;
                        var ChildCaBLen= flightInfo.FlightInfos[n].ChildCabinInfos.length;
                        var nCarBinLength = flightInfo.FlightInfos[n].AduitCabinInfos.length;
                        for (var i = 0; i < nCarBinLength; i++) {
                            var cabinData = flightInfo.FlightInfos[n].AduitCabinInfos[i];

                            var cabinInfo = new laEntityCabinInfo();
                            cabinInfo.CabinName = cabinData.CabinName;
                            cabinInfo.CabinType = cabinData.CabinType;
                            cabinInfo.CabinTypeName = laEntityEnumCabinTypename[cabinData.CabinType];
                            cabinInfo.LeftCount = cabinData.LeftCount;
                            cabinInfo.Discount = cabinData.Discount;
                            cabinInfo.Price = cabinData.Price;
                            for(var j=0; j<ChildCaBLen;j++){
                                if(cabinData.CabinType==flightInfo.FlightInfos[n].ChildCabinInfos[j].CabinType){
                                    cabinInfo.ChildCabinName = flightInfo.FlightInfos[n].ChildCabinInfos[j].ChildCabinName;
                                    cabinInfo.ChildPrice = flightInfo.FlightInfos[n].ChildCabinInfos[j].Price;
                                    cabinInfo.ChildSalePrice = flightInfo.FlightInfos[n].ChildCabinInfos[j].SalePrice;
                                    break;
                                }else {
                                    cabinInfo.ChildPrice = -1;
                                }
                            }
                            for(var j=0; j<InfantCaBLen;j++){
                                if(cabinData.CabinType==flightInfo.FlightInfos[n].InfantCabinInfos[j].CabinType){
                                    cabinInfo.InfantCabinName = flightInfo.FlightInfos[n].InfantCabinInfos[j].InfantCabinName;
                                    cabinInfo.InfantPrice = flightInfo.FlightInfos[n].InfantCabinInfos[j].Price;
                                    cabinInfo.InfantSalePrice = flightInfo.FlightInfos[n].InfantCabinInfos[j].SalePrice;
                                    break;
                                }else {
                                    cabinInfo.InfantPrice = 0;
                                    cabinInfo.InfantSalePrice = 0;
                                }
                            }
                            cabinInfo.SalePrice = cabinData.SalePrice;
                            cabinInfo.PriceBase = cabinData.PriceBase;
                            cabinInfo.ChildPriceBase = cabinData.ChildPriceBase;
                            cabinInfo.InfantPriceBase = cabinData.InfantPriceBase;
                            cabinInfo.RefundRule = cabinData.Rule.RefundRule;
                            cabinInfo.ChangeRule = cabinData.Rule.ChangeRule;
                            cabinInfo.SignedTransfer = cabinData.Rule.SignedTransfer;
                            cabinInfo.SignedTransferDisplay = cabinData.Rule.SignedTransferDisplay;
                            var j=0;
                            var caBFlg =cabinData.Insurances.length;
                            if(caBFlg){
                                var caBlen =cabinData.Insurances.length;
                                for(;j<caBlen;j++){
                                    switch (cabinData.Insurances[j].InsuranceType)
                                    {
                                        case 1:
                                            cabinInfo.DelayInsurancePrice=cabinData.Insurances[j].InsuranceAmount;
                                            cabinInfo.DelaySumInsured = cabinData.Insurances[j].SumInsured;
                                            cabinInfo.DelayInsuranceTktPriceDiscount = cabinData.Insurances[j].OfferAmount;
                                            cabinInfo.DelayInsuranceCanBuyCount = cabinData.Insurances[j].CanBuyCount;
                                            break;
                                        case 2:
                                            cabinInfo.AccidentInsurancePrice=cabinData.Insurances[j].InsuranceAmount;
                                            cabinInfo.AccidentSumInsured = cabinData.Insurances[j].SumInsured;
                                            cabinInfo.AccidentInsuranceTktPriceDiscount = cabinData.Insurances[j].OfferAmount;
                                            cabinInfo.AccidentInsuranceCanBuyCount = cabinData.Insurances[j].CanBuyCount;
                                            break;
                                        case 3:
                                            cabinInfo.BaggageInsurancePrice=cabinData.Insurances[j].InsuranceAmount;
                                            cabinInfo.BaggageSumInsured = cabinData.Insurances[j].SumInsured;
                                            cabinInfo.BaggageInsuranceTktPriceDiscount = cabinData.Insurances[j].OfferAmount;
                                            cabinInfo.BaggageInsuranceCanBuyCount = cabinData.Insurances[j].CanBuyCount;
                                            break;
                                    }
                                }
                            }else{
                                cabinInfo.DelayInsurancePrice=0;
                                cabinInfo.DelaySumInsured = 0;
                                cabinInfo.DelayInsuranceTktPriceDiscount = 0;
                                cabinInfo.DelayInsuranceCanBuyCount = 0;
                                cabinInfo.AccidentInsurancePrice=0;
                                cabinInfo.AccidentSumInsured = 0;
                                cabinInfo.AccidentInsuranceTktPriceDiscount = 0;
                                cabinInfo.AccidentInsuranceCanBuyCount = 0;
                                cabinInfo.BaggageInsurancePrice=0;
                                cabinInfo.BaggageSumInsured = 0;
                                cabinInfo.BaggageInsuranceTktPriceDiscount = 0;
                                cabinInfo.BaggageInsuranceCanBuyCount = 0;
                            }

                            // cabinInfo.AccidentInsurancePrice = cabinData.AccidentInsurancePrice;
                            // cabinInfo.AccidentSumInsured = cabinData.AccidentSumInsured;
                            // cabinInfo.AccidentInsuranceTktPriceDiscount = cabinData.AccidentInsuranceTktPriceDiscount;
                            // cabinInfo.AccidentInsuranceCanBuyCount = cabinData.AccidentInsuranceCanBuyCount;
                            // cabinInfo.DelayInsurancePrice = cabinData.DelayInsurancePrice;
                            // cabinInfo.DelaySumInsured = cabinData.DelaySumInsured;
                            // cabinInfo.DelayInsuranceTktPriceDiscount = cabinData.DelayInsuranceTktPriceDiscount;
                            // cabinInfo.DelayInsuranceCanBuyCount = cabinData.DelayInsuranceCanBuyCount;
                            // cabinInfo.BaggageInsurancePrice = cabinData.BaggageInsurancePrice;
                            // cabinInfo.BaggageSumInsured = cabinData.BaggageSumInsured;
                            // cabinInfo.BaggageInsuranceTktPriceDiscount = cabinData.BaggageInsuranceTktPriceDiscount;
                            // cabinInfo.BaggageInsuranceCanBuyCount = cabinData.BaggageInsuranceCanBuyCount;

                            flightData.CabinInfoList[i] = cabinInfo;
                        }

                        flightList.FlightList[n] = flightData;
                        flightList.FlightList[n].AllFlightInfo=JSON.parse(data.Result);
                    }

                    if (flightInfo.LowPriceFlights != undefined) {
                        var nLowPrice = flightInfo.LowPriceFlights.length;
                        for (var l = 0; l < nLowPrice; l++) {
                            var lowPrice = new laEntityLowPriceFlights();
                            var cd = new Date(flightInfo.LowPriceFlights[l].FlightDate.replace(/-/g, "/"));
                            lowPrice.FlightDate = cd.getFullYear() + "-" + (cd.getMonth() + 1) + "-" + cd.getDate();
                            lowPrice.LowPrice = flightInfo.LowPriceFlights[l].LowPrice;

                            flightList.LowPriceFlights[l] = lowPrice;
                        }
                    }
                }
                callBack(flightList, status);
            }
        )
    };

    /**
     * 查询特价机票
     * @param airportFromCode 出发城市机场编码
     * @param airportToCode 到达城市机场编码
     * @param callBack
     * @constructor
     */
    laFlightService.QuerySpecialTicket = function (airportFromCode, airportToCode, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_QuerySpecialTicket;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = '';
        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.DepartureAirport = airportFromCode;
        requestBody.ArriveAirport = airportToCode;
        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var rs = {};
                if(data.ErrorCode==0){
                    rs.Code = "0000";
                    rs.Message = "";
                    var dataRs=JSON.parse(data.Result);

                }else {
                    rs.Code = data.ErrorCode;
                    rs.Message = data.Result;
                }
                    rs.CityList = new Array();
                    rs.AirLineList = new Array();

                if (rs.Code == laGlobalProperty.laServiceCode_Success) {
                    var n = dataRs.SpecialOfferTicketsInfo.length;
                    var nCity = 0;
                    for (var i = 0; i < n; i++) {
                        var airLine = dataRs.SpecialOfferTicketsInfo[i];

                        var blCity = false;
                        for (var l = 0; l < rs.CityList.length; l++) {
                            if (rs.CityList[l].c == airLine.DepartureAirport) {
                                blCity = true;
                                break;
                            }
                        }
                        if (!blCity) {
                            var aircity = {"c": airLine.DepartureAirport, "n": airLine.DepartureAirportCH};
                            rs.CityList[nCity] = aircity;

                            nCity++;
                        }
                        rs.AirLineList[i] = {
                            "DepartureAirportCode": airLine.DepartureAirport,
                            "DepartureAirportCH": airLine.DepartureAirportCH,
                            "ArriveAirportCode": airLine.ArriveAirport,
                            "ArriveAirportCH": airLine.ArriveAirportCH,
                            "FlightDate": airLine.FlightDate,
                            "FlightWeekName": laGlobalLocalService.getWeekName(new Date(airLine.FlightDate.toString().substr(0, 10).replace(/-/g, "/"))),
                            "Price": airLine.Price,
                            "Index": airLine.Index
                        };
                    }
                }
                callBack(rs, status);
            }
        )
    };

    /**
     * 查询航班动态
     * @param dCityCode 出发城市编码
     * @param aCityCode 到达城市编码
     * @param dTime 出发日期yyyy-MM-dd
     * @param fliNumber 航班号
     * @param qryFlag 0:使用航班号查询;1:使用城市查询;
     * @param callBack
     * @constructor
     */
    laFlightService.QueryFlightDynamic = function (dCityCode, aCityCode, dTime, fliNumber, qryFlag, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_QueryFlightDynamic;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = '';
        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.DepartureCity = dCityCode;
        requestBody.ArriveCity = aCityCode;
        requestBody.DepartureTime = dTime;
        requestBody.FlightNumber = fliNumber;
        requestBody.CityFlag = qryFlag;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var rs = new laEntityBase();
                if(data.ErrorCode==0){
                    rs.Code="0000";
                    rs.Message="";
                    rs.DynamicsResultInfo=JSON.parse(data.Result).Result.DynamicsResultInfo;
                }else {
                    rs.Code=data.ErrorCode;
                    rs.Message=data.Result;
                }
                callBack(rs, status);
            }
        )

    };

    /**
     * 查询机票价格日历
     * @param departureAirportCode 出发机场
     * @param arriveAirportCode 到达机场
     * @param callBack
     * @constructor
     */
    laFlightService.QueryPriceCalendar = function (departureAirportCode, arriveAirportCode, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_QueryPriceCalendar;
        requestParam.SessionId = '';
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.DepartureAirport = departureAirportCode;
        requestBody.ArriveAirport = arriveAirportCode;
        //requestBody.DepartureTime = departureDay;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };
        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var rs = {};
                if(data.ErrorCode==0){
                    rs.Code = "0000";
                    rs.Message = "";
                    rs.LowPrices = JSON.parse(data.Result).LowPrices;
                    var LowLen= rs.LowPrices.length;
                    for(var i=0; i<LowLen;i++){
                        rs.LowPrices[i].DepartureDay=rs.LowPrices[i].FlightDate;
                        rs.LowPrices[i].LowPrice =  rs.LowPrices[i].Price
                    }
                }else {
                    rs.Code=data.ErrorCode;
                    rs.Message=data.Result;
                }
                callBack(rs, status);
            }
        )
    };

    /**
     * 改期航班查询
     * @param departureTime YYYY-MM-DD
     * @param orderId
     * @param changePassengerList
     * @param callBack
     * @constructor
     */
    laFlightService.QueryFlightForTrans = function (departureTime, orderId, changePassengerList, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_QueryFlightForTrans;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();
        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.DepartureTime = departureTime;
        requestBody.OrderId = orderId;
        requestBody.ChangePassengers = changePassengerList;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var fli = data;
            var FlightInfos = new laEntityFlightList();
            if(data.ErrorCode==0){
                FlightInfos.Code = "0000";
                FlightInfos.Message = fli.Message;
            }else {
                FlightInfos.Code=fli.ErrorCode;
                FlightInfos.Message=fli.Result;
            }
            if (status == true && FlightInfos.Code == laGlobalProperty.laServiceCode_Success) {
                var flightInfo = JSON.parse(fli.Result);

                var nFlis = flightInfo.FlightInfos.length;
                for (var n = 0; n < nFlis; n++) {
                    var flightData = new laEntityFlight();
                    flightData.FlightNum = flightInfo.FlightInfos[n].FlightNum;
                    flightData.AirportFrom = flightInfo.FlightInfos[n].AirportFrom;
                    flightData.AirportFromCH = flightInfo.FlightInfos[n].AirportFromCH;
                    flightData.AirportTo = flightInfo.FlightInfos[n].AirportTo;
                    flightData.AirportToCH = flightInfo.FlightInfos[n].AirportToCH;
                    flightData.Distance = flightInfo.FlightInfos[n].Distance;
                    flightData.DepartureTime = flightInfo.FlightInfos[n].DepartureTime;
                    flightData.ArriveTime = flightInfo.FlightInfos[n].ArriveTime;
                    flightData.AirportTax = flightInfo.FlightInfos[n].TaxAdult.AirportTax;
                    flightData.FuelTax = flightInfo.FlightInfos[n].TaxAdult.FuelTax;
                    flightData.FuelTaxDiff = flightInfo.FlightInfos[n].TaxAdult.FuelTaxDiff;
                    flightData.AirportTaxDiff = flightInfo.FlightInfos[n].TaxAdult.AirportTaxDiff;
                    flightData.OtherTax = flightInfo.FlightInfos[n].TaxAdult.OtherTax;
                    flightData.ChildAirportTax = flightInfo.FlightInfos[n].TaxChild.AirportTax;
                    flightData.ChildFuelTax = flightInfo.FlightInfos[n].TaxChild.FuelTax;
                    flightData.ChildOtherTax = flightInfo.FlightInfos[n].TaxChild.OtherTax;
                    flightData.InfantAirportTax = flightInfo.FlightInfos[n].TaxInfant.AirportTax;
                    flightData.InfantFuelTax = flightInfo.FlightInfos[n].TaxInfant.FuelTax;
                    flightData.InfantOtherTax = flightInfo.FlightInfos[n].TaxInfant.OtherTax;
                    flightData.JiXing = flightInfo.FlightInfos[n].JiXing;
                    flightData.JingTing = flightInfo.FlightInfos[n].JingTing;
                    flightData.CabinInfos=new Array();
                    var InfantCaBLen = flightInfo.FlightInfos[n].InfantCabinInfos.length;
                    var ChildCaBLen = flightInfo.FlightInfos[n].ChildCabinInfos.length;
                    var nCarBinLength = flightInfo.FlightInfos[n].AduitCabinInfos.length;
                    for (var i = 0; i < nCarBinLength; i++) {
                        var cabinData = flightInfo.FlightInfos[n].AduitCabinInfos[i];

                        var cabinInfo = new laEntityCabinInfo();
                        cabinInfo.CabinName = cabinData.CabinName;
                        cabinInfo.CabinType = cabinData.CabinType;
                        cabinInfo.CabinTypeName = laEntityEnumCabinTypename[cabinData.CabinType];
                        cabinInfo.LeftCount = cabinData.LeftCount;
                        cabinInfo.Discount = cabinData.Discount;
                        cabinInfo.HandleAmount = cabinData.HandleAmount;
                        cabinInfo.Price = cabinData.Price;
                        cabinInfo.TicketPriceDiff = cabinData.TicketPriceDiff;
                        for (var j = 0; j < ChildCaBLen; j++) {
                            if (cabinData.CabinType == flightInfo.FlightInfos[n].ChildCabinInfos[j].CabinType) {
                                cabinInfo.ChildCabinName = flightInfo.FlightInfos[n].ChildCabinInfos[j].ChildCabinName;
                                cabinInfo.ChildPrice = flightInfo.FlightInfos[n].ChildCabinInfos[j].Price;
                                cabinInfo.ChildSalePrice = flightInfo.FlightInfos[n].ChildCabinInfos[j].SalePrice;
                                break;
                            } else {
                                cabinInfo.ChildPrice = -1;
                            }
                        }
                        for (var j = 0; j < InfantCaBLen; j++) {
                            if (cabinData.CabinType == flightInfo.FlightInfos[n].InfantCabinInfos[j].CabinType) {
                                cabinInfo.InfantCabinName = flightInfo.FlightInfos[n].InfantCabinInfos[j].InfantCabinName;
                                cabinInfo.InfantPrice = flightInfo.FlightInfos[n].InfantCabinInfos[j].Price;
                                cabinInfo.InfantSalePrice = flightInfo.FlightInfos[n].InfantCabinInfos[j].SalePrice;
                                break;
                            } else {
                                cabinInfo.InfantPrice = 0;
                                cabinInfo.InfantSalePrice = 0;
                            }
                        }
                        cabinInfo.SalePrice = cabinData.SalePrice;
                        cabinInfo.PriceBase = cabinData.PriceBase;
                        cabinInfo.ChildPriceBase = cabinData.ChildPriceBase;
                        cabinInfo.InfantPriceBase = cabinData.InfantPriceBase;
                        cabinInfo.RefundRule = cabinData.Rule.RefundRule;
                        cabinInfo.ChangeRule = cabinData.Rule.ChangeRule;
                        cabinInfo.SignedTransfer = cabinData.Rule.SignedTransfer;
                        cabinInfo.SignedTransferDisplay = cabinData.Rule.SignedTransferDisplay;
                        var j = 0;
                        var caBFlg = cabinData.Insurances.length;
                        if (caBFlg) {
                            var caBlen = cabinData.Insurances.length;
                            for (; j < caBlen; j++) {
                                switch (cabinData.Insurances[j].InsuranceType) {
                                    case 1:
                                        cabinInfo.DelayInsurancePrice = cabinData.Insurances[j].InsuranceAmount;
                                        cabinInfo.DelaySumInsured = cabinData.Insurances[j].SumInsured;
                                        cabinInfo.DelayInsuranceTktPriceDiscount = cabinData.Insurances[j].OfferAmount;
                                        cabinInfo.DelayInsuranceCanBuyCount = cabinData.Insurances[j].CanBuyCount;
                                        break;
                                    case 2:
                                        cabinInfo.AccidentInsurancePrice = cabinData.Insurances[j].InsuranceAmount;
                                        cabinInfo.AccidentSumInsured = cabinData.Insurances[j].SumInsured;
                                        cabinInfo.AccidentInsuranceTktPriceDiscount = cabinData.Insurances[j].OfferAmount;
                                        cabinInfo.AccidentInsuranceCanBuyCount = cabinData.Insurances[j].CanBuyCount;
                                        break;
                                    case 3:
                                        cabinInfo.BaggageInsurancePrice = cabinData.Insurances[j].InsuranceAmount;
                                        cabinInfo.BaggageSumInsured = cabinData.Insurances[j].SumInsured;
                                        cabinInfo.BaggageInsuranceTktPriceDiscount = cabinData.Insurances[j].OfferAmount;
                                        cabinInfo.BaggageInsuranceCanBuyCount = cabinData.Insurances[j].CanBuyCount;
                                        break;
                                }
                            }
                        } else {
                            cabinInfo.DelayInsurancePrice = 0;
                            cabinInfo.DelaySumInsured = 0;
                            cabinInfo.DelayInsuranceTktPriceDiscount = 0;
                            cabinInfo.DelayInsuranceCanBuyCount = 0;
                            cabinInfo.AccidentInsurancePrice = 0;
                            cabinInfo.AccidentSumInsured = 0;
                            cabinInfo.AccidentInsuranceTktPriceDiscount = 0;
                            cabinInfo.AccidentInsuranceCanBuyCount = 0;
                            cabinInfo.BaggageInsurancePrice = 0;
                            cabinInfo.BaggageSumInsured = 0;
                            cabinInfo.BaggageInsuranceTktPriceDiscount = 0;
                            cabinInfo.BaggageInsuranceCanBuyCount = 0;
                        }

                        // cabinInfo.AccidentInsurancePrice = cabinData.AccidentInsurancePrice;
                        // cabinInfo.AccidentSumInsured = cabinData.AccidentSumInsured;
                        // cabinInfo.AccidentInsuranceTktPriceDiscount = cabinData.AccidentInsuranceTktPriceDiscount;
                        // cabinInfo.AccidentInsuranceCanBuyCount = cabinData.AccidentInsuranceCanBuyCount;
                        // cabinInfo.DelayInsurancePrice = cabinData.DelayInsurancePrice;
                        // cabinInfo.DelaySumInsured = cabinData.DelaySumInsured;
                        // cabinInfo.DelayInsuranceTktPriceDiscount = cabinData.DelayInsuranceTktPriceDiscount;
                        // cabinInfo.DelayInsuranceCanBuyCount = cabinData.DelayInsuranceCanBuyCount;
                        // cabinInfo.BaggageInsurancePrice = cabinData.BaggageInsurancePrice;
                        // cabinInfo.BaggageSumInsured = cabinData.BaggageSumInsured;
                        // cabinInfo.BaggageInsuranceTktPriceDiscount = cabinData.BaggageInsuranceTktPriceDiscount;
                        // cabinInfo.BaggageInsuranceCanBuyCount = cabinData.BaggageInsuranceCanBuyCount;

                        flightData.CabinInfos[i] = cabinInfo;
                    }

                    FlightInfos.FlightList[n] = flightData;
                    FlightInfos.FlightList[n].AllFlightInfo = JSON.parse(data.Result);
                }
            }
                callBack(FlightInfos, status);
            }
        )

    };

    return laFlightService;
}]);

/**
 * 订单操作类
 */
laOrder.factory('laOrderService', ['$http', 'laGlobalHTTPService', 'laGlobalLocalService', function ($http, laGlobalHTTPService, laGlobalLocalService) {

    var laOrderService = {};

    /**
     * 预定订单
     * @param ordInfo 订单信息
     * @param callBack
     * @constructor
     */
    laOrderService.CreateOrder = function (ordInfo, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_CreateOrder;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = ordInfo.SaleChannel;
        requestBody.ChildRecerveCabinPriceType = ordInfo.ChildRecerveCabinPriceType;
        requestBody.Contacts = ordInfo.Contacts;
        requestBody.Flights = ordInfo.Flights;
        requestBody.InsuranceInfos=new Array();
        requestBody.Passengers = ordInfo.Passengers;
        requestBody.InsuranceInfos=ordInfo.InsuranceInfos;

        /*
         requestBody.Passengers = {};
         for (var i = 0; i < ordInfo.Passengers.length; i++) {
         requestBody.Passengers[i] = ordInfo.Passengers[i];
         }
         */
        requestBody.TotalAmount = ordInfo.TotalAmount;
        requestBody.TotalIntegral = 0;
        requestBody.VerifyCode=ordInfo.VerifyCode;
        requestBody.Address = ordInfo.Itinerary;
        requestBody.ParaParkOrder=ordInfo.ParaParkOrder;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                //{"Result":{"Amount":790,"OrderId":1930272531004402},"Code":"0000","Message":"预定成功"}
                var uInfo={};
                if (data.ErrorCode == 0) {
                    uInfo.Code = "0000";
                    uInfo.Result=JSON.parse(data.Result);

                } else {
                    uInfo.Code = data.ErrorCode;
                    uInfo.Message = data.Result;

                }
                callBack(uInfo, status);
            }
        )
    };

    /**
     * 机票改期
     * @param ordInfo
     * @param callBack
     * @constructor
     */
    laOrderService.TransFlightOrder = function (ordInfo, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_TransFlight;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = ordInfo.SaleChannel;
        requestBody.SaleOrderTid = ordInfo.OrderId;
        requestBody.Contacts = ordInfo.Contacts;
        requestBody.Flights = ordInfo.Flights;
        requestBody.Passengers = ordInfo.Passengers;
        requestBody.Address = ordInfo.Itinerary;
        requestBody.TotalAmount = ordInfo.TotalAmount;
        requestBody.VerifyCode = ordInfo.VerifyCode;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var uInfo={
                Code:"",
                Result:{},
                Message:""
            };
            if (data.ErrorCode == 0) {
                uInfo.Code = "0000";
                uInfo.Result=JSON.parse(data.Result);

            } else {
                uInfo.Code = data.ErrorCode;
                uInfo.Message = data.Result;

            }
                callBack(uInfo, status);

        })
    };

    /**
     * 校验机票是否可以改期
     * @param ordInfo
     * @param callBack
     * @constructor
     */
    laOrderService.CheckCanTransFlight = function (checkTransInfo, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_CheckCanTrans;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = checkTransInfo.SaleChannel;
        requestBody.OrderId = checkTransInfo.OrderId;
        requestBody.ChangePassengers = checkTransInfo.ChangePassenger;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var uInfo={
                Code:"",
                Result:{},
                Message:""
            };
            if (data.ErrorCode == 0) {
                uInfo.Code = "0000";
                uInfo.Result=JSON.parse(data.Result).Result;

            } else {
                uInfo.Code = data.ErrorCode;
                uInfo.Message = data.Result;

            }
                callBack(uInfo, status);
            }
        )
    };

    /**
     * 获取订单支付方式
     * @param callBack
     * @constructor
     */
    laOrderService.GetPayChannel = function (callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_GetPayChannelList;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var channelList = {};
                if(data.ErrorCode==0){
                    channelList.Code="0000";
                }else {
                    channelList.Code = data.Code;
                    channelList.Message = data.Result;
                }
                if (status == true && channelList.Code == laGlobalProperty.laServiceCode_Success) {

                    var n = JSON.parse(data.Result).length;
                    channelList.PayPlat = new Array();
                    channelList.BankList = new Array();
                    channelList.CreditBankList = new Array();

                    var bl = 0;
                    var pl = 0;

                    for (var i = 0; i < n; i++) {
                        var channel = JSON.parse(data.Result)[i];
                        channelList.PayPlat[i] = {
                            "PayPlatCode": channel.PayPlatCode,
                            "PayPlatName": channel.PayPlatCodeDisplay
                        };

                        var l = channel.BankInfos.length;
                        for (var j = 0; j < l; j++) {
                            channelList.BankList[bl] = {
                                "PayPlatCode": channel.PayPlatCode,
                                "BankCode": channel.BankInfos[j].BankCode,
                                "BankName": channel.BankInfos[j].BankName,
                                "ImageName": channel.BankInfos[j].ImageName,
                                "Index": channel.BankInfos[j].DisplayIndex
                            };
                            bl++;
                        }

                        for (var j = 0; j < channelList.CreditBankList.length; j++) {
                            channelList.CreditBankList[pl] = {
                                "PayPlatCode": channel.PayPlatCode,
                                "BankCode": channel.CreditBankInfos[j].BankCode,
                                "BankName": channel.CreditBankInfos[j].BankName,
                                "Index": channel.CreditBankInfos[j].DisplayIndex
                            };
                            pl++;
                        }
                    }
                }
                callBack(channelList, status);
            }
        )
    };

    /**
     * 查询订单列表
     * @param queryOrder
     * @param callBack
     * @constructor
     */
    laOrderService.QueryOrderList = function (queryOrder, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_OrderList;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.NewPageIndex = queryOrder.NewPageIndex;
        requestBody.OnePageCount = queryOrder.OnePageCount;
        requestBody.TicketOrderNum = queryOrder.TicketOrderNum;
        requestBody.FlightNum = queryOrder.FlightNum;
        requestBody.PassengerName = queryOrder.Flier;
        requestBody.CreateTimeStart = queryOrder.CreateTimeStart;
        requestBody.CreateTimeEnd = queryOrder.CreateTimeEnd;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var rs = data;
                var ds={};
                var ordList = new laEntityOrderList();
                if(data.ErrorCode==0){
                    ordList.Code="0000";
                    ordList.Message="";
                    ordList.Result=JSON.parse(data.Result);
                    ds.Result=JSON.parse(data.Result);
                }else {
                    ordList.Code=data.ErrorCode;
                    ordList.Message=data.Result;
                }
                if (status == true && ordList.Code == laGlobalProperty.laServiceCode_Success) {
                    ordList.NowPageIndex = ds.Result.NowPageIndex;
                    ordList.TotalPage = ds.Result.TotalPage;
                    ordList.OnePageCount = ds.Result.OnePageCount;
                    ordList.DataCount = ds.Result.DataCount;

                    var nlen = ds.Result.OrderList.length;
                    for (var i = 0; i < nlen; i++) {
                        var ordDet = laOrderService.ParseSimOrderInfo(ds.Result.OrderList[i]);
                        ordList.OrderList[i] = ordDet;
                    }
                }
                callBack(ordList, status);
            }
        )
    };

    /**
     * 把订单信息解析成对象
     * @param orderInfoJson
     * @constructor
     */
    laOrderService.ParseSimOrderInfo = function (orderInfoJson) {
        var ordDet = orderInfoJson;
        var ordInfo = new laEntityOrderInfoDetail();
        ordInfo.SaleOrderTid=ordDet.SaleOrderTid;
        ordInfo.OrderStatus = ordDet.OrderStatus;
        ordInfo.OrderStatusCH = ordDet.OrderStatusCH;
        ordInfo.PayStatus = ordDet.PayStatus;
        ordInfo.PayStatusCH = ordDet.PayStatusCH;
        ordInfo.CreateTime = ordDet.CreateTime;
        ordInfo.OrderType = ordDet.OrderType;
        ordInfo.OrderTypeCH = ordDet.OrderTypeCH;
        ordInfo.IntegralType = ordDet.IntegralType;
        ordInfo.IntegralTypeCH = ordDet.IntegralTypeCH;
        ordInfo.ParkOrderDetail = ordDet.ParkOrderTotal;
        ordInfo.ParkOrderList = ordDet.ParkOrderList;
        ordInfo.PayTime = ordDet.PayTime;
        ordInfo.PayPlat = ordDet.PayPlat;
        ordInfo.OrderId = ordDet.Tid;
        ordInfo.Contacts.ContactsAddress = ordDet.Contacts.ContactsAddress;
        ordInfo.Contacts.ContactsEMail = ordDet.Contacts.ContactsEMail;
        ordInfo.Contacts.ContactsMobile = ordDet.Contacts.ContactsMobile;
        ordInfo.Contacts.ContactsName = ordDet.Contacts.ContactsName;
        ordInfo.Contacts.ContactsPhone = ordDet.Contacts.ContactsPhone;
        ordInfo.Contacts.ContactsZIP = ordDet.Contacts.ContactsZIP;
        ordInfo.Address = ordDet.Address;
        if (ordDet.Address != null && ordDet.Address != undefined) {
            if (ordDet.Address.ExpressChange != null && ordDet.Address.ExpressChange != undefined) {
                ordInfo.OrderAmountWithTax += ordDet.Address.ExpressChange;
            }
        }

        var flightId = '';
        var nFlilen = 0;
        var nPsg = ordDet.Passengers.length;
        for (var i = 0; i < nPsg; i++) {
            var psg = new laEntityOrderInfoDetPassengers();
            var tmpPsg = ordDet.Passengers[i];
            psg.PassengerId = tmpPsg.PassengerId;
            psg.PassengerName = tmpPsg.PassengerName;
            psg.Foid = tmpPsg.Foid;
            psg.FoidType = tmpPsg.FoidType;
            psg.FoidTypeDisplay = tmpPsg.FoidTypeDisplay;
            psg.TravellerType = tmpPsg.TravellerType;
            psg.TravellerTypeDisplay = tmpPsg.TravellerTypeDisplay;
            psg.Brithday = tmpPsg.Brithday;

            var nFli = ordDet.Passengers[i].Flights.length;
            for (var n = 0; n < nFli; n++) {
                var fli = new laEntityOrderInfoDetPsgFlights();
                var tmpFli = ordDet.Passengers[i].Flights[n];
                fli.FlightId = tmpFli.FlightId;
                fli.FlightNum = tmpFli.FlightNum;
                fli.DepartureAirport = tmpFli.DepartureAirport;
                fli.DepartureAirportCH = tmpFli.DepartureAirportCH;
                fli.DepartureCity = tmpFli.DepartureCity;
                fli.DepartureCityCH = tmpFli.DepartureCityCH;
                fli.ArriveAirport = tmpFli.ArriveAirport;
                fli.ArriveAirportCH = tmpFli.ArriveAirportCH;
                fli.ArriveCity = tmpFli.ArriveCity;
                fli.ArriveCityCH = tmpFli.ArriveCityCH;
                fli.DepartureTime = tmpFli.DepartureTime;
                fli.ArriveTime = tmpFli.ArriveTime;
                fli.Cabin = tmpFli.Cabin;
                fli.SaleTicketPrice = tmpFli.SaleTicketPrice;
                fli.SaleIntegral = tmpFli.SaleIntegral;
                fli.TicketPrice = tmpFli.TicketPrice;
                fli.FuelTax = tmpFli.FuelTax;
                fli.AirportTax = tmpFli.AirportTax;
                fli.OtherTax = tmpFli.OtherTax;
                fli.ChangeHandleFee = tmpFli.ChangeHandleFee;
                fli.ETKT = tmpFli.ETKT;
                fli.JiXing = tmpFli.JiXing;
                fli.JingTing = tmpFli.JingTing;
                fli.CabinType = tmpFli.CabinType;
                fli.PriceBase = tmpFli.PriceBase;
                fli.RefundRule = tmpFli.RefundRule;
                fli.ChangeRule = tmpFli.ChangeRule;
                fli.SignedTransfer = tmpFli.SignedTransfer;
                fli.CanRefund = tmpFli.CanRefund;
                fli.CanErrorRefund = tmpFli.CanErrorRefund;
                fli.CanInvoluntary = tmpFli.CanInvoluntary;
                fli.CanNotRefundNote = tmpFli.CanNotRefundNote;
                fli.CanNotErrorRefundNote = tmpFli.CanNotErrorRefundNote;
                fli.CanNotInvoluntaryNote = tmpFli.CanNotInvoluntaryNote;
                fli.CanTrans = tmpFli.CanTrans;
                fli.RefundStatus = tmpFli.RefundStatus;
                fli.RefundAmountStatus = tmpFli.RefundAmountStatus;
                fli.RefundIntegralStatus = tmpFli.RefundIntegralStatus;
                fli.RefundIntegral = tmpFli.RefundIntegral;
                fli.WaitRefundIntegral = tmpFli.WaitRefundIntegral;
                fli.TicketRefundAmount = tmpFli.TicketRefundAmount;
                fli.InsuranceAmount = tmpFli.InsuranceAmount;
                fli.WaitTicketRefundAmount = tmpFli.WaitTicketRefundAmount;
                fli.WaitInsuranceAmount = tmpFli.WaitInsuranceAmount;
                fli.RefundFirstAduitStatus = tmpFli.RefundFirstAduitStatus;
                fli.RefundSecondAduitStatus = tmpFli.RefundSecondAduitStatus;
                fli.RefundFirstNote = tmpFli.RefundFirstNote;
                fli.RefundSecondNote = tmpFli.RefundSecondNote;
                fli.RefundAduitTime = tmpFli.RefundAduitTime;
                fli.Insurances = tmpFli.Insurances;
                fli.TicketPriceDifference = tmpFli.TicketPriceDifference;
                fli.OldTicketHandleAmount = tmpFli.OldTicketHandleAmount;
                fli.TransStatus = tmpFli.TransStatus;

                var chFee = 0;
                if (tmpFli.ChangeHandleFee != undefined && tmpFli.ChangeHandleFee != null) {
                    chFee = tmpFli.ChangeHandleFee;
                }
                if (5 == ordInfo.OrderType) {
                    ordInfo.OrderAmountWithTax += tmpFli.TicketPriceDifference;
                    ordInfo.OrderAmountWithTax += tmpFli.FuelTaxDifference + tmpFli.AirportTaxDifference + tmpFli.OtherTax + chFee;

                } else {
                    ordInfo.OrderAmountWithTax += tmpFli.SaleTicketPrice;
                    ordInfo.OrderAmountWithTax += tmpFli.FuelTax + tmpFli.AirportTax + tmpFli.OtherTax + chFee;
                }

                for (var x = 0; x < fli.Insurances.length; x++) {
                    var ins = fli.Insurances[x];
                    ordInfo.OrderAmountWithTax += ins.InsuranceAmount;
                }
                ordInfo.OrderAmountWithTax+=

                ordInfo.OrderIntegral += tmpFli.SaleIntegral;

                psg.AllTktAmount += tmpFli.SaleTicketPrice;
                psg.AllTicketPriceDiff += tmpFli.TicketPriceDifference;
                psg.AllTktIntegral += tmpFli.SaleIntegral;
                if (5 == ordInfo.OrderType){
                    psg.AllAirportAmount += tmpFli.AirportTaxDifference;
                    psg.AllFuelAmount += tmpFli.FuelTaxDifference;
                    psg.AllOtherAmount += tmpFli.OtherTax;
                }else {
                    psg.AllAirportAmount += tmpFli.AirportTax;
                    psg.AllFuelAmount += tmpFli.FuelTax;
                    psg.AllOtherAmount += tmpFli.OtherTax;
                }
                psg.AllChangeHandleFee += (tmpFli.ChangeHandleFee == undefined || tmpFli.ChangeHandleFee == null) ? 0 : tmpFli.ChangeHandleFee;
                for (var s = 0; s < tmpFli.Insurances.length; s++) {
                    var inam = 0;
                    if (tmpFli.Insurances[s].InsuranceAmount != undefined && tmpFli.Insurances[s].InsuranceAmount != null) {
                        inam = tmpFli.Insurances[s].InsuranceAmount;
                    }
                    fli.InsAmount += inam;
                    psg.AllInsurancesAmount += inam;
                }

                psg.Flights[n] = fli;

                if (flightId.indexOf(tmpFli.FlightNum + ',' + tmpFli.DepartureTime, 0) < 0) {
                    var fliSim = new laEntityOrderInfoDetFlights();
                    fliSim.FlightId = tmpFli.FlightId;
                    fliSim.FlightNum = tmpFli.FlightNum;
                    fliSim.DepartureAirport = tmpFli.DepartureAirport;
                    fliSim.DepartureAirportCH = tmpFli.DepartureAirportCH;
                    fliSim.DepartureCity = tmpFli.DepartureCity;
                    fliSim.DepartureCityCH = tmpFli.DepartureCityCH;
                    fliSim.ArriveAirport = tmpFli.ArriveAirport;
                    fliSim.ArriveAirportCH = tmpFli.ArriveAirportCH;
                    fliSim.ArriveCity = tmpFli.ArriveCity;
                    fliSim.ArriveCityCH = tmpFli.ArriveCityCH;
                    fliSim.DepartureTime = tmpFli.DepartureTime;
                    fliSim.ArriveTime = tmpFli.ArriveTime;
                    fliSim.JiXing = tmpFli.JiXing;
                    fliSim.JingTing = tmpFli.JingTing;
                    fliSim.Cabin = tmpFli.Cabin;
                    fliSim.CabinType = tmpFli.CabinType;

                    ordInfo.FlightList[nFlilen] = fliSim;

                    flightId += '|' + tmpFli.FlightNum + ',' + tmpFli.DepartureTime + '|';
                    nFlilen++;
                }
            }

            ordInfo.Passengers[i] = psg;
        }
        if(ordDet.PaymentMethods!=null){
            var nPay = ordDet.PaymentMethods.length;
            var channelList = {};
            channelList.PayPlat = new Array();
            channelList.BankList = new Array();
            channelList.CreditBankList = new Array();
            var bl = 0;
            var pl = 0;

            for (var i = 0; i < nPay; i++) {
                var channel = ordDet.PaymentMethods[i];
                channelList.PayPlat[i] = {
                    "PayPlatCode": channel.PayPlatCode,
                    "PayPlatName": channel.PayPlatCodeDisplay
                };

                var l = channel.BankInfos.length;
                for (var j = 0; j < l; j++) {
                    channelList.BankList[bl] = {
                        "PayPlatCode": channel.PayPlatCode,
                        "BankCode": channel.BankInfos[j].BankCode,
                        "BankName": channel.BankInfos[j].BankName,
                        "ImageName": channel.BankInfos[j].ImageName,
                        "Index": channel.BankInfos[j].DisplayIndex
                    };
                    bl++;
                }

                for (var j = 0; j < channel.CreditBankInfos.length; j++) {
                    channelList.CreditBankList[pl] = {
                        "PayPlatCode": channel.PayPlatCode,
                        "BankCode": channel.CreditBankInfos[j].BankCode,
                        "BankName": channel.CreditBankInfos[j].BankName,
                        "ImageName": channel.CreditBankInfos[j].ImageName,
                        "Index": channel.CreditBankInfos[j].DisplayIndex
                    };
                    pl++;
                }
            }
            ordInfo.PaymentMethods = channelList;
        }



        return ordInfo;
    };

    /**
     * 查询订单详细信息
     * @param orderId
     * @param callBack
     * @constructor
     */
    laOrderService.QueryOrderInfo = function (orderId, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_OrderInfo;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.OrderId = orderId;
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };
        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var ord = {};
                var ordInfo = new laEntityOrderInfoDetail();
                if(data.ErrorCode==0){
                    ord.Code="0000";
                    ord.Message="";
                    ord.Result=JSON.parse(data.Result).Result;
                }else {
                    ord.Code=data.ErrorCode;
                    ordInfo.Message=data.Result;
                }
                if (status == true && ord.Code == laGlobalProperty.laServiceCode_Success) {
                    ordInfo = laOrderService.ParseSimOrderInfo(ord.Result);
                    ordInfo.Code = ord.Code;
                    ordInfo.Message = ord.Message;
                }
                callBack(ordInfo, status);

                /*
                 var ord = data;
                 var ordInfo = new laEntityOrderInfoDetail();
                 ordInfo.Code = ord.Code;
                 ordInfo.Message = ord.Message;
                 if (status == true && ordInfo.Code == laGlobalProperty.laServiceCode_Success) {
                 var ordDet = ord.Result;
                 ordInfo.OrderStatus = ordDet.OrderStatus;
                 ordInfo.OrderStatusCH = ordDet.OrderStatusCH;
                 ordInfo.PayStatus = ordDet.PayStatus;
                 ordInfo.PayStatusCH = ordDet.PayStatusCH;
                 ordInfo.CreateTime = ordDet.CreateTime;
                 ordInfo.OrderType = ordDet.OrderType;
                 ordInfo.OrderTypeCH = ordDet.OrderTypeCH;
                 ordInfo.PayTime = ordDet.PayTime;
                 ordInfo.PayPlat = ordDet.PayPlat;
                 ordInfo.OrderId = ordDet.Tid;
                 ordInfo.Contacts.ContactsAddress = ordDet.Contacts.ContactsAddress;
                 ordInfo.Contacts.ContactsEMail = ordDet.Contacts.ContactsEMail;
                 ordInfo.Contacts.ContactsMobile = ordDet.Contacts.ContactsMobile;
                 ordInfo.Contacts.ContactsName = ordDet.Contacts.ContactsName;
                 ordInfo.Contacts.ContactsPhone = ordDet.Contacts.ContactsPhone;
                 ordInfo.Contacts.ContactsZIP = ordDet.Contacts.ContactsZIP;

                 var flightId = '';
                 var nFlilen = 0;
                 var nPsg = ordDet.Passengers.length;
                 for (i = 0; i < nPsg; i++) {
                 var psg = new laEntityOrderInfoDetPassengers();
                 var tmpPsg = ordDet.Passengers[i];
                 psg.PassengerId = tmpPsg.PassengerId;
                 psg.PassengerName = tmpPsg.PassengerName;
                 psg.Foid = tmpPsg.Foid;
                 psg.FoidType = tmpPsg.FoidType;
                 psg.FoidTypeDisplay = tmpPsg.FoidTypeDisplay;
                 psg.TravellerType = tmpPsg.TravellerType;
                 psg.TravellerTypeDisplay = tmpPsg.TravellerTypeDisplay;
                 psg.Brithday = tmpPsg.Brithday;

                 var nFli = ordDet.Passengers[i].Flights.length;
                 for (n = 0; n < nFli; n++) {
                 var fli = new laEntityOrderInfoDetPsgFlights();
                 var tmpFli = ordDet.Passengers[i].Flights[n];
                 fli.FlightId = tmpFli.FlightId;
                 fli.FlightNum = tmpFli.FlightNum;
                 fli.DepartureAirport = tmpFli.DepartureAirport;
                 fli.DepartureAirportCH = tmpFli.DepartureAirportCH;
                 fli.DepartureCity = tmpFli.DepartureCity;
                 fli.DepartureCityCH = tmpFli.DepartureCityCH;
                 fli.ArriveAirport = tmpFli.ArriveAirport;
                 fli.ArriveAirportCH = tmpFli.ArriveAirportCH;
                 fli.ArriveCity = tmpFli.ArriveCity;
                 fli.ArriveCityCH = tmpFli.ArriveCityCH;
                 fli.DepartureTime = tmpFli.DepartureTime;
                 fli.ArriveTime = tmpFli.ArriveTime;
                 fli.Cabin = tmpFli.Cabin;
                 fli.SaleTicketPrice = tmpFli.SaleTicketPrice;
                 fli.TicketPrice = tmpFli.TicketPrice;
                 fli.FuelTax = tmpFli.FuelTax;
                 fli.AirportTax = tmpFli.AirportTax;
                 fli.OtherTax = tmpFli.OtherTax;
                 fli.ETKT = tmpFli.ETKT;
                 fli.JiXing = tmpFli.JiXing;
                 fli.JingTing = tmpFli.JingTing;
                 fli.CabinType = tmpFli.CabinType;
                 fli.PriceBase = tmpFli.PriceBase;
                 fli.RefundRule = tmpFli.RefundRule;
                 fli.ChangeRule = tmpFli.ChangeRule;
                 fli.SignedTransfer = tmpFli.SignedTransfer;
                 fli.CanRefund = tmpFli.CanRefund;
                 fli.CanTrans = tmpFli.CanTrans;
                 fli.RefundStatus = tmpFli.RefundStatus;
                 fli.RefundAmountStatus = tmpFli.RefundAmountStatus;

                 ordInfo.OrderAmountWithTax += tmpFli.SaleTicketPrice + tmpFli.FuelTax + tmpFli.AirportTax + tmpFli.OtherTax;

                 psg.AllTktAmount += tmpFli.SaleTicketPrice;
                 psg.AllAirportAmount += tmpFli.AirportTax;
                 psg.AllFuelAmount += tmpFli.FuelTax;
                 psg.AllOtherAmount += tmpFli.OtherTax;

                 psg.Flights[n] = fli;

                 if (flightId.indexOf(tmpFli.FlightId, 0) < 0) {
                 var fliSim = new laEntityOrderInfoDetFlights();
                 fliSim.FlightId = tmpFli.FlightId;
                 fliSim.FlightNum = '';
                 fliSim.DepartureAirport = tmpFli.DepartureAirport;
                 fliSim.DepartureAirportCH = tmpFli.DepartureAirportCH;
                 fliSim.DepartureCity = tmpFli.DepartureCity;
                 fliSim.DepartureCityCH = tmpFli.DepartureCityCH;
                 fliSim.ArriveAirport = tmpFli.ArriveAirport;
                 fliSim.ArriveAirportCH = tmpFli.ArriveAirportCH;
                 fliSim.ArriveCity = tmpFli.ArriveCity;
                 fliSim.ArriveCityCH = tmpFli.ArriveCityCH;
                 fliSim.DepartureTime = tmpFli.DepartureTime;
                 fliSim.ArriveTime = tmpFli.ArriveTime;
                 fliSim.JiXing = tmpFli.JiXing;
                 fliSim.JingTing = tmpFli.JingTing;
                 fliSim.Cabin = tmpFli.Cabin;
                 fliSim.CabinType = tmpFli.CabinType;
                 ordInfo.FlightList[nFlilen] = fliSim;

                 flightId += '|' + tmpFli.FlightId + '|';
                 nFlilen++;
                 }
                 }

                 ordInfo.Passengers[i] = psg;
                 }
                 }
                 callBack(ordInfo, status);
                 */

            }
        )
    };

    /**
     * 补订儿童/婴儿票时根据票号姓名查航班信息
     * @param queryInfo
     * @constructor
     */
    laOrderService.QueryOrderInfoForBabyTicket = function (queryInfo, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_SpecialServiceDetrTN;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = '';

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.TktNo = queryInfo.TktNo;
        requestBody.Name = queryInfo.PassengerName;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var dataBack={};
            if(data.ErrorCode==0){
                dataBack=JSON.parse(data.Result);
                dataBack.Code="0000";
                dataBack.Message="";
            }else {
                dataBack.Code=data.ErrorCode;
                dataBack.Message=data.Result;
            }
                callBack(dataBack, status);
            }
        )
    };
    /**
     * 根据票号姓名查行程信息
     * @param queryInfo
     * @param callBack
     * @constructor
     */
    laOrderService.QueryItineraryOrderDetr = function (queryInfo, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_ItineraryOrderDetr;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.TktNo = queryInfo.TktNo;
        requestBody.Name = queryInfo.PassengerName;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var dataBack={};
            if(data.ErrorCode==0){
                dataBack=JSON.parse(data.Result);
                dataBack.Code="0000";
                dataBack.Message="";
            }else {
                dataBack.Code=data.ErrorCode;
                dataBack.Message=data.Result;
            }
                callBack(dataBack, status);
            }
        )
    };
    /**
     * 创建行程单订单
     * @param orderInfo
     * @param callBack
     * @constructor
     */
    laOrderService.CreateItineraryOrder = function (orderInfo, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_CreateItineraryOrder;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        /*requestBody.ConsigneeName = orderInfo.ConsigneeName;
        requestBody.ConsigneeMobile = orderInfo.ConsigneeMobile;
        requestBody.ConsigneePhone = orderInfo.ConsigneePhone;
        requestBody.ConsigneeProvince = orderInfo.ConsigneeProvince;
        requestBody.ConsigneeCity = orderInfo.ConsigneeCity;
        requestBody.ConsigneeDistrict = orderInfo.ConsigneeDistrict;
        requestBody.ConsigneeDetialAddress = orderInfo.ConsigneeDetialAddress;
        requestBody.ConsigneePostCode = orderInfo.ConsigneePostCode;
        requestBody.ExpressProviderType = orderInfo.ExpressProviderType;
        requestBody.PassengerName = orderInfo.PassengerName;
        requestBody.TicketNo = orderInfo.TicketNo;
        requestBody.Departure = orderInfo.Departure;
        requestBody.Arrive = orderInfo.Arrive;
        requestBody.FlightNo = orderInfo.FlightNo;
        requestBody.FlightDate = orderInfo.FlightDate;*/
        requestBody.Address = orderInfo.consigneeAddress;
        requestBody.ExpressProviderType = orderInfo.expressProviderType;
        requestBody.ExpressAmount = orderInfo.expressAmount;
        requestBody.ItineraryTKNInfo = orderInfo.itineraryTKNInfo;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var uInfo = {
                Code:"",
                Message:"",
                ItineraryOrderResp:{}
            };
            if (data.ErrorCode == 0) {
                uInfo.Code = "0000";
                uInfo.ItineraryOrderResp=JSON.parse(data.Result);
            } else {
                uInfo.Code = data.ErrorCode;
                uInfo.Message = data.Result;

            }
                callBack(uInfo, status);
            }
        )
    };
    /**
     * 查询行程单订单列表
     * @param queryInfo
     * @param callBack
     * @constructor
     */
    laOrderService.QueryItineraryOrderList = function (queryInfo, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_QueryItineraryOrderList;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.SubmitStartDate = queryInfo.StartDate;
        requestBody.SubmitEndDate = queryInfo.EndDate;
        requestBody.ItineraryOrderStatue = queryInfo.OrderStatue;
        requestBody.UISearchPages={
            NowPage : queryInfo.NowPage,
            OnePageCount : queryInfo.OnePageCount,
            DataCount :0,
            PageCount :0,
            StartIndex :0,

        }

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var uInfo = {
                    Code:"",
                    Message:"",
                    ItineraryOrderDetailList:[]
                };
                if (data.ErrorCode == 0) {
                    uInfo.Code = "0000";
                    uInfo.ItineraryOrderDetailList=JSON.parse(data.Result);
                } else {
                    uInfo.Code = data.ErrorCode;
                    uInfo.Message = data.Result;

                }
                callBack(uInfo, status);
            }
        )
    };

    /**
     * 获取行程单订单支付链接
     * @param orderId
     * @param payPlatCode
     * @param bankCode
     * @param payUrlType
     * @param callBack
     * @constructor
     */
    laOrderService.GetItineraryOrderPayUrl = function (orderId, payPlatCode, bankCode, payUrlType, callBack) {
        var requestParam = {};
        requestParam.ActionType = laGlobalProperty.laServiceUrl_ActionType_PayItineraryOrderUrl;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.OrderId = orderId;
        requestBody.PayPlatCode = payPlatCode;
        requestBody.BankCode = bankCode;
        requestBody.PayUrlType = payUrlType;

        requestParam.Args = JSON.stringify(requestBody);

        var postData = JSON.stringify(requestParam);

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                callBack(data, status);
            }
        )
    };
    /**
     * 查询行程单订单列表详情
     * @param ordId
     * @param callBack
     * @constructor
     */
    laOrderService.QueryItineraryOrderDetail = function (ordId, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_QueryItineraryOrderDetail;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.ItineraryOrderTid = ordId;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var backData={};
            if(data.ErrorCode==0){
                backData=JSON.parse(data.Result);
                backData.Message="";
                backData.Code="0000";

            }else {
                backData.Message=data.Result;
                backData.Code=data.ErrorCode;
            }
                callBack(backData, status);
            }
        )
    };
    /**
     * 创建行程单退款订单
     * @param ordInfo
     * @param callBack
     * @constructor
     */
    laOrderService.CreateRefundItineraryOrder = function (ordInfo, callBack) {
        var requestParam = {};
        requestParam.ActionType = laGlobalProperty.laServiceUrl_ActionType_CreateRefundItineraryOrder;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.ItineraryOrderId = ordInfo.ItineraryOrderId;
        requestBody.RefundAmount = ordInfo.RefundAmount;
        requestBody.ContactsName = ordInfo.ContactsName;
        requestBody.ContactsEMail = ordInfo.ContactsEMail;
        requestBody.ContactsMobile = ordInfo.ContactsMobile;
        requestBody.Remark = ordInfo.Remark;

        requestParam.Args = JSON.stringify(requestBody);

        var postData = JSON.stringify(requestParam);

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                callBack(data, status);
            }
        )
    };
    /**
     * 未登录状态下查询订单信息的查询验证码
     * @param callBack
     * @constructor
     */
    laOrderService.ImageVerifyCodeForQueryOrderInfoWithoutLogin = function (callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_OrderInfoImgVerifyCode;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.VerifyCodeType="OrderDetialNotLogin";

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var backData={};
            if(data.ErrorCode==0){
                backData=JSON.parse(data.Result);
                backData.Message="";
                backData.Code="0000";

            }else {
                backData.Message=data.Result;
                backData.Code=data.ErrorCode;
            }
            callBack(backData, status);
            }
        )
    };

    /**
     * 未登录状态下查询订单信息
     * @param orderId
     * @param mobile
     * @param imageVerifyCode
     * @param sessionId
     * @param callBack
     * @constructor
     */
    laOrderService.QueryOrderInfoWithoutLogin = function (orderId, mobile, imageVerifyCode, sessionId, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_OrderInfoWithoutLogin;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = sessionId;

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.TicketOrderTotalTid = orderId;
        requestBody.Mobile = mobile;
        requestBody.ImageVerifyCode = imageVerifyCode;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                var ord = {
                    Code:"",
                    Message:"",
                    SignKey:""
                };
                var ordInfo = new laEntityOrderInfoDetail();
                if (status == true && data.ErrorCode == 0) {
                    ord.Result=JSON.parse(data.Result).Result;
                    ord.Code="0000";
                    ord.SignKey=JSON.parse(data.Result).SignKey;
                    ordInfo = laOrderService.ParseSimOrderInfo(ord.Result);
                    ordInfo.Code = ord.Code;
                    ordInfo.Message = ord.Message;
                    ordInfo.SignKey = ord.SignKey;
                }else {
                    ordInfo.Code = data.ErrorCode;
                    ordInfo.Message = data.Result;
                }
                callBack(ordInfo, status);
            }
        )
    };

    /**
     * 获取支付链接
     * @param orderId 订单号
     * @param payPlatCode 支付平台编码
     * @param bankCode 银行代码
     * @param payUrlType Url类型 1:url;2:form
     * @param callBack
     * @constructor
     */
    laOrderService.GetPayUrl = function (orderId, payPlatCode, bankCode, payUrlType, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_PayUrl;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.OrderTid = orderId;
        requestBody.PayPlatCode = payPlatCode;
        requestBody.Bank = bankCode;
        requestBody.PayUrlType = payUrlType;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var ordInfo = {
                Code:"",
                Message:"",
                Result:{}
            };
            if (data.ErrorCode == 0) {
                ordInfo.Code = "0000";
                ordInfo.Message = "";
                ordInfo.Result.PayUrlInfo = JSON.parse(data.Result).PayUrl;
            }else {
                ordInfo.Code = data.ErrorCode;
                ordInfo.Message = data.Result;
            }
                callBack(ordInfo, status);
            }
        )
    };

    /**
     * 取消订单
     * @param orderId
     * @param callBack
     * @constructor
     */
    laOrderService.CancelOrder = function (orderId, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_CancelOrder;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.OrderTid = orderId;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var ordInfo = {
                Code:"",
                Message:"",
            };
            if (data.ErrorCode == 0) {
                ordInfo.Code = "0000";
                ordInfo.Message = "";
            }else {
                ordInfo.Code = data.ErrorCode;
                ordInfo.Message = "";
            }
                callBack(ordInfo, status);
            }
        )
    };
    /**
     * 获取停车城市和价格
     * @param r 停车信息
     * @param callBack
     * @constructor
     */
    laOrderService.ReturnParkCityUnitPrice = function (r, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_ReturnParkCityUnitPrice;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.CitySzm = r.CitySzm;
        requestBody.Company = r.Company;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var backData={};
            if(data.ErrorCode==0){
                backData=JSON.parse(data.Result);
                backData.Code="0000";
                backData.Message="";

            }else {
                backData.Code=data.ErrorCode;
                backData.Message=data.Result;
            }

                callBack(backData, status);
            }
        )
    };
    /**
     * 退停车订单
     * @param r 停车信息
     * @param callBack
     * @constructor
     */
    laOrderService.ParaRefundParkOrder = function (r, callBack) {
        var requestParam = {};
        requestParam.ActionType = laGlobalProperty.laServiceUrl_ActionType_RefundParkOrder;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.ParkOrderId = r.ParkOrderId;
        requestBody.RefundAmount = r.RefundAmount;
        requestBody.Remark = r.Remark;
        requestBody.ContactsName = r.ContactsName;
        requestBody.ContactsEMail = r.ContactsEMail;
        requestBody.ContactsMobile = r.ContactsMobile;

        requestParam.Args = JSON.stringify(requestBody);

        var postData = JSON.stringify(requestParam);

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
                callBack(data, status);
            }
        )
    };

    /**
     * 退票
     * @param r 退票信息
     * @param callBack
     * @constructor
     */
    laOrderService.RefundOrder = function (r, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_RefundOrder;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.OrderId = r.SaleOrderTid;
        requestBody.RefundType = r.RefundType;
        requestBody.Note = r.Note;
        requestBody.ContactsName = r.ContactsName;
        requestBody.ContactsEMail = r.ContactsEMail;
        requestBody.ContactsMobile = r.ContactsMobile;
        requestBody.Passengers = r.Passengers;
        requestBody.RefundAmount = r.RefundAmount;
        requestBody.FileGuid = r.FileGuid;
        requestBody.InvoluntaryRefundType = r.InvoluntaryRefundType;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var ordInfo = {
                Code:"",
                Message:"",
            };
            if (data.ErrorCode == 0) {
                ordInfo.Code = "0000";
                ordInfo.Message = "";
            }else {
                ordInfo.Code = data.ErrorCode;
                ordInfo.Message = data.Result;
            }
                callBack(ordInfo, status);
            }
        )
    };

    /**
     * 未登录状态下退票
     * @param r
     * @param callBack
     * @constructor
     */
    laOrderService.RefundOrderWithoutLogin = function (r, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_RefundOrderWithoutLogin;
        requestParam.SessionId = r.sessionId;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.OrderId = r.OrderId;
        requestBody.RefundType = r.RefundType;
        requestBody.Note = r.Note;
        requestBody.ContactsName = r.ContactsName;
        requestBody.ContactsEMail = r.ContactsEMail;
        requestBody.ContactsMobile = r.ContactsMobile;
        requestBody.Passengers = r.Passengers;
        requestBody.RefundAmount = r.RefundAmount;
        requestBody.SignKey = r.SignKey;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var ordInfo = {
                Code:"",
                Message:"",
            };
            if (data.ErrorCode == 0) {
                ordInfo.Code = "0000";
                ordInfo.Message = "";
            }else {
                ordInfo.Code = data.ErrorCode;
                ordInfo.Message = "";
            }
                callBack(ordInfo, status);
            }
        )
    };

    /**
     * 客票验真图片验证码
     * @param callBack
     * @constructor
     */
    laOrderService.ImageVerifyCodeForCheckTicket = function (VerifyCodeType,callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_ImageVerifyCodeForRegister
        requestParam.SessionId = '';
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.VerifyCodeType=VerifyCodeType;
        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };
        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            if(data.ErrorCode==0){
                data={
                    Code:"0000",
                    Message:"",
                    ImageVerifyCode:(JSON.parse(data.Result)).VerifyCode,
                    SessionID:data.Result.SessionID
                }
            }else {
                data = {
                    Code: "0001",
                    Message: data.Result
                }
            }
                callBack(data, status);
            }
        )
    };

    /**
     * 客票验真
     * @param ticketNum 票号
     * @param passengerName 旅客姓名
     * @param imageVerifyCode 图片验证码
     * @param sessionId
     * @param callBack
     * @constructor
     */
    laOrderService.CheckTicket = function (ticketNum, passengerName, imageVerifyCode, sessionId, callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_CheckTicket;
        requestParam.SessionId = sessionId;
        requestParam.AppID=laGlobalProperty.laServiceConst_AppId;

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;
        requestBody.TicketNo = ticketNum;
        requestBody.Name = passengerName;
        requestBody.ImageCode = imageVerifyCode;

        requestParam.Parameters = JSON.stringify(requestBody);
        var postData = { paras: JSON.stringify(requestParam) };

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            var rsData={}
            if(data.ErrorCode==0){
                rsData.Message=JSON.parse(data.Result).CheckResult;
                rsData.Code="0000";

            }else {
                rsData.Code=data.ErrorCode;
                rsData.Message=data.Result;

            }

                callBack(rsData, status);
            }
        )
    };

    /**
     * 获取预定机票时的验证码
     * @param callBack
     * @constructor
     */
    laOrderService.ImageVerifyCodeForBookingTicketValidCode = function (callBack) {
        var requestParam = {};
        requestParam.MethodName = laGlobalProperty.laServiceUrl_ActionType_BookingTicketValidCode;
        requestParam.AppID = laGlobalProperty.laServiceConst_AppId;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;

        requestBody.VerifyCodeType = 8;

        requestParam.Parameters = JSON.stringify(requestBody);

        var postData = {paras: JSON.stringify(requestParam)};

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {
            if (data.ErrorCode == 0) {
                data = {
                    Code: "0000",
                    Message: "",
                    ImageVerifyCode: (JSON.parse(data.Result)).VerifyCode,
                    SessionID: data.Result.SessionID
                }
            } else {
                data = {
                    Code: "0001",
                    Message: data.Result
                }
            }
                callBack(data, status);
            }
        )
    };

    laOrderService.QueryRefundOrderInfo = function (callBack) {
        var requestParam = {};
        requestParam.ActionType = laGlobalProperty.laServiceUrl_ActionType_RefundOrderInfo;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;

        requestParam.Args = JSON.stringify(requestBody);

        var postData = JSON.stringify(requestParam);

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {

            }
        )
    };

    laOrderService.QueryRefundOrderList = function (callBack) {
        var requestParam = {};
        requestParam.ActionType = laGlobalProperty.laServiceUrl_ActionType_RefundOrderList;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;

        requestParam.Args = JSON.stringify(requestBody);

        var postData = JSON.stringify(requestParam);

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {

            }
        )
    };

    laOrderService.QueryRefundOrderPassenger = function (callBack) {
        var requestParam = {};
        requestParam.ActionType = laGlobalProperty.laServiceUrl_ActionType_RefundOrderPassenger;
        requestParam.SessionId = laGlobalLocalService.getCurrentUserSessionId();

        var requestBody = {};
        requestBody.SaleChannel = laGlobalProperty.laServiceCode_SaleChannel;

        requestParam.Args = JSON.stringify(requestBody);

        var postData = JSON.stringify(requestParam);

        laGlobalHTTPService.requestByPostUrl(postData, function (data, status) {

            }
        )
    };

    return laOrderService;
}]);